#include <stdexcept>
class Solution {
public:
    string compressString(string param) {
        int n = param.size();
        string ret;
        int left = 0, right = 0;
        while (right < n)
        {
            ret.push_back(param[left]);
            while (param[left] == param[right]) right++;
            int len = right - left;
            if (len > 1)
                ret += to_string(len);
            left = right;
        }

        return ret;
    }
};
